package com.winona.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.taplinker.client.R;
import com.winona.ConstantValue;
import com.winona.bean.Paper;

public class AcademicAdapter extends BaseListAdapter<Paper> {

	protected AcademicAdapter(Context context, ArrayList<Paper> list,
			int defaultId) {
		super(context, list, defaultId);
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView = convertView;
		PaperViewHolder viewHolder = null;

		if (rowView == null) {
			viewHolder = new PaperViewHolder();
			rowView = mInflater.inflate(R.layout.sensivive_item, null);
			viewHolder.tv_name = (TextView) rowView
					.findViewById(R.id.sensitive_name);
			viewHolder.iv_logo = (ImageView) rowView
					.findViewById(R.id.sensitive_img);
			viewHolder.description = (TextView) rowView
					.findViewById(R.id.sensitive_description);

			rowView.setTag(viewHolder);
		} else {
			viewHolder = (PaperViewHolder) rowView.getTag();
		}

		Paper paperObj = mList.get(position);
		viewHolder.tv_name.setText(paperObj.getAcademicProject().getName());
		viewHolder.iv_logo.setImageURI(Uri.parse(ConstantValue.IMAGE
				+ paperObj.getAcademicProject().getImageUrl()));

		viewHolder.description.setText(paperObj.getAcademicProject()
				.getContent());
		return rowView;
	}

	private class PaperViewHolder {
		TextView tv_name = null; //
		ImageView iv_logo = null;
		TextView description = null;
	}

}
